package objetosGraficos;

import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class tanteador extends JPanel{

	private ImageIcon [] numeros;
	private JLabel [] labels;
	private int puntaje = 0;
	
	public tanteador (){
		this.setLayout(new FlowLayout(FlowLayout.RIGHT));
		this.setSize(150,30);
		this.setPreferredSize(new Dimension(150,30));
		this.numeros = new ImageIcon[10];
		this.setOpaque(false);
		for (int i = 0; i < 10; i++)
			numeros[i] = SpriteStore.get().getImage(i+"");
		
		this.labels = new JLabel[7];
		for (int i = 6; i >= 0 ; i--){
			labels[i] = new JLabel();
			labels[i].setIcon(numeros[0]);
			this.add(labels[i]);
		}
		this.repaint();
	}
	
	public void aumentarPuntaje(int p){
		puntaje += p;
		int aux = puntaje;
		int i = 0;
		while (aux > 0){			
			int digito = aux % 10;
			labels[i].setIcon(numeros[digito]);
			i++;
			aux /= 10;
		}
		this.repaint();
	}
}
